package me.monster.smarttraffic.base;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import me.monster.smarttraffic.R;
import me.monster.smarttraffic.tool.ActivityPop;
import me.monster.toolbarhelper.toolview.tools.ToolBarHelper;

/**
 * @description
 * @author: Created jiangjiwei in 2020-02-11 15:47
 */
public abstract class AbstractToolActivity extends BaseActivity {

    public ToolBarHelper toolHelper;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View closeToolView = closeToolView();

        View layoutRoot = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
        if (closeToolView != null) {
            toolHelper = new ToolBarHelper(layoutRoot, closeToolView, getInitTitle());
            toolHelper.setPopProvider(new ActivityPop());
            toolHelper.setBgColor(R.color.colorPrimaryDark);
        }
    }

    /**
     * 最靠近顶部的 View
     *
     * @return
     */
    public abstract View closeToolView();

    /**
     * 初始化时的 标题名称
     *
     * @return
     */
    public abstract String getInitTitle();
}
